<template>
  <div>
    <p>欢迎你:{{ name }}小朋友</p>
    <p>你当前所在年级为: {{ cla.cla.name }}</p>
    <ul>
      <li v-for="i in cla.cla.courses">{{ i.name }}</li>
    </ul>
    <button v-if="cla.cla.type<3" @click="changeCla">升班</button>
  </div>
</template>

<script>
export default {
  data() {
    return {
      name: localStorage.getItem('name'),
      id: localStorage.getItem('id'),
      cla: {}
    }
  },
  methods: {
    getStuMes() {
      this.axios.get('/?id=' + this.id)
        .then(res => {
          this.cla = res.data.cla
        })
    },
    changeCla() {
      this.axios.post('', {'id': this.id})
        .then(res => {
          this.getStuMes()
        })
    }
  },
  mounted() {
    this.getStuMes()
  }
}
</script>

<style scoped>

</style>
